Skip to content

Delete threads with no replies #6578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025
Merged

Conversation

akatsoulas
Copy link
Collaborator

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the deletion of threads that have no replies while reassigning threads that do have replies to the sumo bot. Key changes include:

  • Updating tests in both forums and kbforums to verify that threads with no replies are deleted and threads with replies are reassigned.
  • Modifying ThreadListener and PostListener in both forums and kbforums to reflect the new deletion and reassignment logic.
  • Adjusting test data creation to include a replies count for threads.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
kitsune/forums/tests/test_handlers.py Added tests for empty thread deletion and updated post creation in threads.
kitsune/kbforums/tests/test_handlers.py Updated thread creation to include replies count and added empty thread deletion tests.
kitsune/kbforums/handlers.py Changed ThreadListener to reassign threads with replies and delete others.
kitsune/forums/handlers.py Updated ThreadListener and PostListener to perform reassignment and thread deletion.
Comments suppressed due to low confidence (1)

kitsune/forums/handlers.py:19

  • Consider explicitly filtering for empty threads (e.g., using 'replies=0') when deleting threads. This change would improve code clarity and reduce any risk if the update to reassign threads does not take effect as expected.
threads_to_delete.delete()

Comment on lines +13 to 14
Thread.objects.filter(creator=user).delete()

Copy link
Preview

Copilot AI Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider explicitly filtering for threads with no replies (e.g., adding 'replies=0') during deletion to ensure that only threads with no replies are removed.

Suggested change
Thread.objects.filter(creator=user).delete()
Thread.objects.filter(creator=user, replies=0).delete()

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@escattone escattone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @akatsoulas!

Comment on lines 18 to 19
threads_to_reassign.update(creator=Profile.get_sumo_bot())
threads_to_delete.delete()
Copy link
Contributor

@escattone escattone Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nit. I think it would be easier to read/understand with the variables replaced with their actual queries like you do within the KB forums handler.

@akatsoulas akatsoulas merged commit c6137c7 into mozilla:main Mar 21, 2025
2 checks passed
@akatsoulas akatsoulas deleted the forum-replies branch March 21, 2025 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants